//
//  HighlightReplaysTableViewCell.m
//  Gxj
//
//  Created by 刘伟 on 2017/10/12.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "HighlightReplaysTableViewCell.h"

static NSString * cellID = @"highlightReplays";

@interface HighlightReplaysTableViewCell () <UICollectionViewDelegate,UICollectionViewDataSource>

@end

@implementation HighlightReplaysTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self.contentView addSubview:self.theCollectionView];
    }
    return self;
}

- (UICollectionView *)theCollectionView
{
    if (_theCollectionView == nil) {
        UICollectionViewFlowLayout * flowLayout = [[UICollectionViewFlowLayout alloc]init];
        flowLayout.itemSize = CGSizeMake(kWidthScale(183), kHeightScale(162));
        flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        flowLayout.minimumLineSpacing = kWidthScale(-5);
        _theCollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(kWidthScale(0), kHeightScale(10), UIScreenWidth, kHeightScale(162)) collectionViewLayout:flowLayout];
        _theCollectionView.dataSource = self;
        _theCollectionView.delegate = self;
        _theCollectionView.backgroundColor = [UIColor clearColor];
        
        [_theCollectionView registerClass:[HighlightReplaysCollectionViewCell class] forCellWithReuseIdentifier:cellID];
    }
    return _theCollectionView;
}

#pragma mark - UICollectionViewDelegate,UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section;
{
    return 2;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    HighlightReplaysCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
    if (!cell)
    {
        cell = [[HighlightReplaysCollectionViewCell alloc] initWithFrame:CGRectMake(kWidthScale(0), kHeightScale(0), kWidthScale(183), kHeightScale(140))];
    }
    
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.clickMeetingPlayback) {
        self.clickMeetingPlayback([NSString stringWithFormat:@"%ld",indexPath.row]);
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
